<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand" />
	<meta http-equiv="X-UA-Compatible" content="IE=9; IE=8; IE=7; IE=EDGE">
	<title>课堂资源-精准微课堂</title>
	<%@ include file="/common/commonLib.jsp"%>
	<link rel="stylesheet" type="text/css" href="<c:url value='/css/classroomIndex.css'/>" />
	<link rel="stylesheet" type="text/css" href="<c:url value='/css/classroomResource.css'/>" />
	<link rel="stylesheet" type="text/css" href="<c:url value='/css/common-main.css'/>"/>
	<script src="<c:url value='/js/classroomIndex.js'/>" type="text/javascript" charset="utf-8"></script>
	<script src="<c:url value='/js/main.js'/>" type="text/javascript" charset="utf-8"></script>
	<script src="<c:url value='/js/classroomResource.js'/>" type="text/javascript" charset="utf-8"></script>
</head>

<body>
	
	<div class="container-fluid main">
		<%@include file="/common/header.jsp"%>
		<%@include file="common/classroomHeader.jsp"%>
		<div class="row">
			<div class="col-md-1"></div>
			<div class="col-xs-12 col-sm-12 col-md-10">
				<%@include file="common/classroomNav.jsp"%>
				<div style="margin-top:2rem;">
					<table class="table table-hover">
						<thead>
							<tr>
								<th>资源名</th>
								<th>上传者</th>
								<th>上传时间</th>
								<th>下载</th>
							</tr>
						</thead>
						<tbody id="resourceList">
							
						</tbody>
					</table>
				</div>
			</div>
			<div class="col-md-1"></div>
		</div>
	</div>
	<%@include file="/common/footer.jsp"%>
</body>
<script>
var data=${data};
$(document).ready(function(){
	if (data.status != "success"){
		alert(data.message);
		return;
	}
	$("#classroom-href-resource").css("color","#00b43c");
	initLesson(data.data.lessonId);//初始化课堂信息
	initTable(data.data);
	changeLessonUrl(data.data.lessonId);//初始化导航链接
});

var initTable = function(data){
	var resourceList =$("#resourceList");
	resourceList.empty();
	if(data.list.length <= 0){
		var s="<tr><td colspan=\"4\">暂无资源</td></tr>";
		resourceList.append(s);
	}else{
		for(var i=0;i<data.list.length;i++){
			var item =data.list[i];
			var s="<tr>";
			s+="<td title=\""+item.fileName+"\">"+item.fileName+"</td>";
			s+="<td title=\""+item.uploaderName+"\">"+item.uploaderName+"</td>";
			s+="<td title=\""+item.uploadTime+"\">"+item.uploadTime+"</td>";
			s+="<td><a href=\"<c:url value='/resource/download/"+item.url+"'/>\">下载</a></td";
			s+="</tr>"
			resourceList.append(s);
		}
	}
}

</script>
</html>